package cn.edu.cdp.dumpling.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {

    private Integer code; //编码：1成功，0和其它数字为失败
    private String msg; //错误信息
    private Object data; //数据


    public static R success(Object object) {
        R r = new R();
        r.data = object;
        r.code = 1;
        return r;
    }

    public static R success(String msg, Object object) {
        R r = new R();
        r.msg = msg;
        r.data = object;
        r.code = 1;
        return r;
    }

    public static R error(String msg) {
        R r = new R();
        r.msg = msg;
        r.code = 0;
        return r;
    }
}
